package com.bwie.shop.controller;

import com.bwie.common.domain.Shop;
import com.bwie.common.domain.request.ShopReq;
import com.bwie.common.result.Result;
import com.bwie.shop.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ShopController
 * @Description 描述
 * @Author ShiYu.Cui
 * @Date 2024/4/25 9:34
 */
@RestController
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 列表模糊查询
     * @param shopReq
     * @return
     */
    @PostMapping("/shopList")
    public List<Shop> shopList(@RequestBody ShopReq shopReq){
        return shopService.shopList(shopReq);
    }

    /**
     * 添加
     * @param shop
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody Shop shop){
        shopService.add(shop);
        return Result.success();
    }

    @GetMapping("/findById")
    public Result findById(@RequestParam Integer id){
        Result result=shopService.findById(id);
        return result;
    }

    /**
     * 修改
     * @param shop
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody Shop shop){
        shopService.update(shop);
        return Result.success();
    }
}
